# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
_pkgname=usbboot
pkgname=raspberrypi-usbboot
_pkgver=2021.07.01
pkgver="${_pkgver//./}"
pkgrel=2
pkgdesc="rpiboot and bin2c from Raspberry Pi"
url="https://github.com/raspberrypi/usbboot"
arch="all"
license="Apache-2.0"
makedepends="libusb-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/raspberrypi/usbboot/archive/refs/tags/v$_pkgver.tar.gz
	patch-main.c.patch
	"
options="!check !strip" # No tests and don't strip .elf files.
builddir="$srcdir/$_pkgname-$_pkgver"

build() {
	make CFLAGS="$CFLAGS"
}

package() {
	mkdir -p "$pkgdir"/bin
	cp rpiboot bin2c "$pkgdir"/bin

	install -Dm644 -t "$pkgdir"/usr/lib/udev/rules.d debian/99-rpiboot.rules

	mkdir -p "$pkgdir"/usr/share/rpiboot/msd
	cp msd/bootcode.bin "$pkgdir"/usr/share/rpiboot/msd
	cp msd/bootcode4.bin "$pkgdir"/usr/share/rpiboot/msd
	cp msd/start.elf "$pkgdir"/usr/share/rpiboot/msd
	cp msd/start4.elf "$pkgdir"/usr/share/rpiboot/msd
	cp -R recovery "$pkgdir"/usr/share/rpiboot
}

sha512sums="
864b8ebae034c40e386023225a86e2b38b526ec91aff7eda4d76ac3a291a2a883d95c37441ea77cc4772f31ac38b356a55a7046c16081df7be33e7bfb48cfa88  raspberrypi-usbboot-20210701.tar.gz
fa0a625f6f42ffc620b0cade0dedc12e1e664dc4df9745f8a9224ec185a881601eedd2c40684a55a7229f2d41cc148ba1bf0cab274e00e7679b39b304244d0fa  patch-main.c.patch
"
